package com.ysyx.ysyx_ordersetstatu.mqlistener;

import com.ysyx.ysyx_ordersetstatu.service.OrderPojoService;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 *
 * @description: xxxx接口/类
 * @author:郭宇轩
 * @create:2023/4/15 15:15
 */
@Component
@RocketMQMessageListener(topic="order",selectorExpression = "passengerCancel",consumerGroup = "passengerCancel_cGroup")
public class OrderPassengerCancelListener implements RocketMQListener<MessageExt>, RocketMQPushConsumerLifecycleListener {

    @Autowired
    private OrderPojoService orderPojoService;
    @Override
    public void onMessage(MessageExt messageExt) {
        System.out.println("乘客取消订单MQ=="+ new String(messageExt.getBody()));
        String orderInfo = new String(messageExt.getBody());
        orderPojoService.passengerCancelDaoMQ(orderInfo);
    }

    @Override
    public void prepareStart(DefaultMQPushConsumer defaultMQPushConsumer) {

    }
}
